import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './assets/css/index.css'
import './assets/css/icon.css'
import ElementUI from 'element-ui'// 导入组件库
import 'element-ui/lib/theme-chalk/index.css'// 导入组件相关样式
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'//富文本编辑
// 富文本require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
axios.defaults.baseURL='http://127.0.0.1:8888/api/private/v1/'
//axios请求拦截器，为每个请求发送前添加token
axios.interceptors.request.use(function (config) {
  //在发送ajajx之前对配置文件进行操作
  config.headers.Authorization=window.sessionStorage.getItem('token')
  return config
})

Vue.prototype.$http=axios
Vue.prototype.$message=ElementUI.Message
Vue.prototype.$confirm=ElementUI.MessageBox.confirm
//注册为全局组件
Vue.use(ElementUI)
Vue.use(VueQuillEditor)
//注册为全局组件
Vue.component('tree-table',TreeTable)
Vue.config.productionTip = false
//时间格式过滤器
Vue.filter('timeForm',function (val) {
  var dt=new Date(val)
  const y=dt.getFullYear()
  //不够两位，自动吧0补上
  const m=(dt.getMonth()+1+'').padStart(2,"0")
  const d=(dt.getDate()+'').padStart(2,"0")
  const hh=(dt.getHours()+'').padStart(2,"0")
  const mm=(dt.getMinutes()+'').padStart(2,"0")
  const ss=(dt.getSeconds()+'').padStart(2,"0")
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
